
class Cell{
  private boolean state;
  private boolean futurestate;
  private boolean locked;

  public Cell(){
    state = false;
    futurestate = false;
    locked = false;
  }

  public void Birth(){
    futurestate = true;
  }

  public void Death(){
    futurestate = false;
  }

  public void Lock(){
    locked = true;
  }

  public void Free(){
    locked = false;
  }

  public void Update(){
    if (!locked){
      state = futurestate;
    }
  }
  
  public void Evolve(int an){
    // an = alive neighbours
    if ((an == 3)&&(!state)){
      Birth();
    }
    if ((an<2)||(an>3)){
      Death();
    }
  }

  public boolean IsAlive(){
    return state;
    }
}
